* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 28px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #f5f7fa;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
  color: #666;
  font-size: 16px;
}

#main-content {
  padding: 30px 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Insights Section */
.insights-section {
  margin-bottom: 40px;
}

.insights-section h2 {
  font-size: 24px;
  color: #333;
  margin-bottom: 20px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.insight-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.3s;
  border-left: 4px solid #667eea;
}

.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.insight-card.positive {
  border-left-color: #48bb78;
}

.insight-card.warning {
  border-left-color: #f56565;
}

.insight-icon {
  font-size: 36px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f4ff;
  border-radius: 12px;
}

.insight-content {
  flex: 1;
}

.insight-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.insight-value {
  font-size: 28px;
  font-weight: 700;
  color: #333;
  margin-bottom: 4px;
}

.insight-subtitle {
  font-size: 12px;
  color: #999;
}

/* Dashboard Sections */
.dashboard-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dashboard-section h2 {
  font-size: 24px;
  color: #333;
  margin-bottom: 25px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 20px;
  color: #333;
  margin: 0;
}

/* Two Column Grid */
.two-column-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin-top: 20px;
}

.chart-column {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 25px;
}

.chart-column h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
}

.chart-insight {
  margin-top: 15px;
  padding: 15px;
  background: #f0f4ff;
  border-radius: 8px;
  font-size: 14px;
  color: #555;
}

/* Chart Styles */
.chart-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
  height: 350px;
}

.chart-container canvas {
  max-height: 350px;
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

.chart-area {
  position: relative;
  height: 220px;
  padding: 15px 15px 15px 60px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #ffffff;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  height: 160px;
  padding: 0 8px;
  gap: 3px;
}

.chart-bar {
  flex: 1;
  max-width: 22px;
  min-width: 18px;
  background-color: #667eea;
  border-radius: 2px 2px 0 0;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

#day-chart-bars .chart-bar {
  flex: 1;
  max-width: none;
  min-width: 40px;
}

.chart-bar:hover {
  background-color: #5568d3;
  transform: scaleY(1.02);
}

.chart-bar-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-weight: 500;
}

.chart-bar:hover .chart-bar-tooltip {
  opacity: 1;
}

.chart-labels {
  display: flex;
  height: 25px;
  padding: 0 8px;
  font-size: 9px;
  color: #666666;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

.chart-label {
  flex: 1;
  max-width: 22px;
  min-width: 18px;
  text-align: center;
  font-weight: 500;
}

#day-chart-labels .chart-label {
  flex: 1;
  max-width: none;
  min-width: 40px;
}

.chart-axis-y {
  position: absolute;
  left: 8px;
  top: 15px;
  bottom: 40px;
  width: 45px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 9px;
  color: #666666;
}

.chart-axis-y-label {
  text-align: right;
  font-weight: 500;
}

/* Sleep Analysis */
.sleep-analysis {
  margin-top: 20px;
}

.sleep-metric {
  margin-bottom: 25px;
}

.sleep-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.sleep-value {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin-bottom: 10px;
}

.sleep-bar {
  height: 12px;
  background: #e9ecef;
  border-radius: 6px;
  overflow: hidden;
}

.sleep-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.5s ease;
}

.sleep-recommendations {
  margin-top: 30px;
  padding: 20px;
  background: #f0f4ff;
  border-radius: 8px;
}

.sleep-recommendations h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 15px;
}

.sleep-recommendations ul {
  list-style: none;
  padding: 0;
}

.sleep-recommendations li {
  padding: 10px 0;
  border-bottom: 1px solid #e0e0e0;
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

.sleep-recommendations li:last-child {
  border-bottom: none;
}

.sleep-recommendations li.priority-high {
  color: #f56565;
  font-weight: 500;
}

.sleep-recommendations li::before {
  content: "💡 ";
  margin-right: 8px;
}

/* Category Breakdown */
.category-breakdown {
  padding: 20px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.category-name {
  min-width: 120px;
  font-size: 14px;
  color: #333;
  font-weight: 500;
}

.category-bar {
  flex: 1;
  height: 10px;
  background: #e9ecef;
  border-radius: 5px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.5s ease;
}

.category-value {
  min-width: 50px;
  text-align: right;
  font-size: 14px;
  color: #666;
  font-weight: 600;
}

/* Table Styles */
.table-column {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 25px;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: 1;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  max-height: 500px;
}

table {
  width: 100%;
  border-collapse: collapse;
  flex: 1;
  overflow-y: auto;
}

table thead th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  padding: 15px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

table thead th:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a4190 100%);
}

table tbody td {
  padding: 12px;
  border-bottom: 1px solid #e9ecef;
  font-size: 14px;
}

table tbody tr:hover {
  background-color: #f8f9fa;
}

.domain-cell {
  font-weight: 600;
  color: #333;
}

.url-cell {
  max-width: 300px;
  word-wrap: break-word;
}

.url-cell a {
  color: #667eea;
  text-decoration: none;
}

.url-cell a:hover {
  text-decoration: underline;
}

.visit-count {
  font-weight: 600;
  color: #48bb78;
}

.percentage {
  color: #666;
}

.category-cell {
  font-size: 12px;
  color: #666;
  text-transform: capitalize;
}

.date-cell {
  color: #666;
}

.screen-time-cell {
  font-weight: 600;
  color: #667eea;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.page-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: #5568d3;
  transform: translateY(-1px);
}

.page-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.page-info {
  font-weight: 500;
  color: #666;
  font-size: 14px;
}

/* Export Button */
.export-btn {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.export-btn:hover {
  background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
  transform: translateY(-1px);
}

/* Summary Section */
.summary-content {
  padding: 20px 0;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.summary-header h3 {
  font-size: 24px;
  color: #333;
  margin: 0;
}

.health-score {
  text-align: center;
}

.health-score-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
  display: block;
}

.health-score-value {
  font-size: 36px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  display: inline-block;
}

.health-score-value.positive {
  color: #48bb78;
  background: rgba(72, 187, 120, 0.1);
}

.health-score-value.warning {
  color: #f56565;
  background: rgba(245, 101, 101, 0.1);
}

.health-score-value.negative {
  color: #c53030;
  background: rgba(197, 48, 48, 0.1);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.summary-stat {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.summary-stat .stat-icon {
  font-size: 32px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
}

.summary-stat .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  margin-bottom: 5px;
}

.summary-stat .stat-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-insights {
  margin-top: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.summary-insights h4 {
  font-size: 18px;
  color: #333;
  margin-bottom: 15px;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: white;
  border-radius: 6px;
  border-left: 4px solid #667eea;
}

.insight-item.positive {
  border-left-color: #48bb78;
  background: rgba(72, 187, 120, 0.05);
}

.insight-item.warning {
  border-left-color: #f56565;
  background: rgba(245, 101, 101, 0.05);
}

.insight-item .insight-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.insight-item .insight-text {
  flex: 1;
  color: #555;
  line-height: 1.6;
  font-size: 14px;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .two-column-grid {
    grid-template-columns: 1fr;
  }
  
  .insights-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .summary-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }
  
  .summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  header {
    padding: 15px 20px;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }
  
  header h1 {
    font-size: 24px;
  }
  
  #main-content {
    padding: 20px;
  }
  
  .insights-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-column {
    padding: 15px;
  }
  
  .dashboard-section {
    padding: 20px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .table-container {
    max-height: 400px;
  }
  
  table {
    font-size: 12px;
  }
  
  table thead th {
    padding: 10px 8px;
    font-size: 12px;
  }
  
  table tbody td {
    padding: 8px;
    font-size: 12px;
  }
  
  .summary-stats {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .summary-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .health-score {
    width: 100%;
    margin-top: 20px;
  }
}
